// Engine System Class
// (c) jimon game studio

#include "CSystem.h"

#ifdef JE_WIN
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#endif

#ifdef JE_LINUX
#include <time.h>
#endif

namespace je
{
	namespace core
	{
		IMPLEMENT_SINGLETON(System,JE_ENGINE_FUNCTION_CALL)

		//! Constructor
		CSystem::CSystem()
		{
			SetSystem(this);
		}

		//! Destructor
		CSystem::~CSystem()
		{
			SetSystem(NULL);
		}

		//! Sleep System
		void CSystem::SystemSleep(f32 Time)
		{
			#ifdef JE_WIN
			Sleep((DWORD)Time);
			#endif

			#ifdef JE_LINUX
			struct timespec SleepTime;
			SleepTime.tv_sec = (time_t)(Time/1000);
			SleepTime.tv_nsec = Time*1000000;
			nanosleep(&SleepTime,NULL);
			#endif
		}
	}
}
